﻿/*  ----------------------------------------------------------------------------
 *  Microsoft Public License (http://www.microsoft.com/opensource/licenses.mspx#Ms-PL)
 *  
 *  ----------------------------------------------------------------------------
 *  DynamicAspect
 *  ----------------------------------------------------------------------------
 *  File:       AspectChainTest.cs
 *  Author:     NiceWk (n9walker@hotmail.com)
 *  ----------------------------------------------------------------------------
 */

using Bizall.Dynamic.Aspect;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using DynamicAspectTester.Mocks;

namespace DynamicAspectTester
{
    
    
    /// <summary>
    ///This is a test class for AspectChainTest and is intended
    ///to contain all AspectChainTest Unit Tests
    ///</summary>
    [TestClass()]
    public class AspectChainTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


    

        /// <summary>
        ///A test for AfterGetValue
        ///</summary>
        [TestMethod()]
        public void AfterGetValueTest()
        {
            AspectChain target = new AspectChain(); 
            WeavingContext context = null;
            MyAspect aspect =new MyAspect();
            target.AddLast(aspect);

            target.AfterGetValue(context);
            Assert.IsTrue(aspect.AfterGet);
        }

        /// <summary>
        ///A test for AfterMethodCall
        ///</summary>
        [TestMethod()]
        public void AfterMethodCallTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.AfterMethodCall(context);
            Assert.IsTrue(aspect.AfterCall);
        }

        /// <summary>
        ///A test for AroundMethodcall
        ///</summary>
        [TestMethod()]
        public void AroundMethodcallTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);
            aspect.HasAround = true;
            target.AroundMethodcall(context);
            Assert.IsTrue(aspect.AroundCall);
        }

        /// <summary>
        ///A test for BeforeGetValue
        ///</summary>
        [TestMethod()]
        public void BeforeGetValueTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.BeforeGetValue(context);
            Assert.IsTrue(aspect.BeforeGet);
        }

        /// <summary>
        ///A test for BeforeMethodCall
        ///</summary>
        [TestMethod()]
        public void BeforeMethodCallTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.BeforeMethodCall(context);
            Assert.IsTrue(aspect.BeforeCall);
        }

        /// <summary>
        ///A test for ExceptionMethodCall
        ///</summary>
        [TestMethod()]
        public void ExceptionMethodCallTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.ExceptionMethodCall(context, null);
            Assert.IsTrue(aspect.ExceptionCall);
        }

        /// <summary>
        ///A test for HasAroundMethod
        ///</summary>
        [TestMethod()]
        public void HasAroundMethodTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);
            aspect.HasAround = true;
            target.HasAroundMethod(context);
            Assert.IsTrue(aspect.HasAround);
        }

        /// <summary>
        ///A test for PropertyChanged
        ///</summary>
        [TestMethod()]
        public void PropertyChangedTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.PropertyChanged(context);
            Assert.IsTrue(aspect.AfterSet);
        }

        /// <summary>
        ///A test for PropertyChanging
        ///</summary>
        [TestMethod()]
        public void PropertyChangingTest()
        {
            AspectChain target = new AspectChain();
            WeavingContext context = null;
            MyAspect aspect = new MyAspect();
            target.AddLast(aspect);

            target.PropertyChanging(context);
            Assert.IsTrue(aspect.BeforeSet);
        }
    }
}